<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: LeoXie <380019813@qq.com>
// +----------------------------------------------------------------------
namespace plugins\send_mobile_sms\model;
use think\Model;

class PluginMobileCodeSMSModel extends Model
{
    function SendSMS($user_id, $user_name, $user_pwd, $mobile, $Content){
        $url="http://api.sms.cn/sms/?";
        $id = $user_name;//帐号
        $pwd = $user_pwd;//密码
        $content = urlencode('{"code":'.$Content.'}');//发送短信内容
        $rdata = 'ac=send&uid='.$user_name.'&pwd='.$pwd.'&template='.$user_id.'&mobile='.$mobile.'&content='.$content;
        $ch = curl_init();//初始化
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $rdata);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
}